/*
This codefile contains the functionality of the "SerialRead" 
component, specified in the design report ("tussenrapport.doc").

Author:			Geert, Daan
Version: 		1
Last modified:	09-06-11
*/

/*
Read out and return a character received on the serial connection. 
If an overflow error has occured, we return -1.
*/
unsigned char Serial_Getch ()
{
	unsigned char ch;
	if (SSR1_ORE)
	{
		ch = SIDR1; // reset error flags
		return (-1);
	}
	else
	{
		ch = SIDR1; // read out character
		return (ch);
	}
}

/*
If there's new data received on the serial interface, read it out and pass it on for interpreting.
*/
void SerialRead_CheckInput ()
{
	if (SSR1_RDRF == ON)
	{
		AbstractApplication_ParseMessage(Serial_Getch());
	}
}